function isCheck() {
    var check = $("#lightSwitch")
    if(check.attr("checked")){
        open();
    }else {
        close();
    }
}

function queryLightStatus() {
    query();
}

var url = "lightCtrl/handleLight";
var closeData={
    "version": 0,
    "cid": "clubD098628898",
    "type": 0,
    "cmd": 0,
    "commandDatas": [
        {
            "key": 1,
            "value": "1"
        },
        {
            "key": 2,
            "value": "1"
        },
        {
            "key": 3,
            "value": "1"
        },
        {
            "key": 4,
            "value": "1"
        },
        {
            "key": 5,
            "value": "1"
        },
        {
            "key": 6,
            "value": "1"
        },
        {
            "key": 7,
            "value": "1"
        },
        {
            "key": 8,
            "value": "1"
        },
        {
            "key": 9,
            "value": "1"
        },
        {
            "key": 10,
            "value": "1"
        },
        {
            "key": 11,
            "value": "1"
        },
        {
            "key": 12,
            "value": "1"
        },
        {
            "key": 13,
            "value": "1"
        },
        {
            "key": 14,
            "value": "1"
        },
        {
            "key": 15,
            "value": "1"
        },
        {
            "key": 16,
            "value": "1"
        }
    ]
};

var openData = {
    "version": 0,
    "cid": "clubD098628898",
    "type": 0,
    "cmd": 1,
    "commandDatas": [
        {
            "key": 1,
            "value": "0"
        },
        {
            "key": 2,
            "value": "0"
        },
        {
            "key": 3,
            "value": "0"
        },
        {
            "key": 4,
            "value": "0"
        },
        {
            "key": 5,
            "value": "0"
        },
        {
            "key": 6,
            "value": "0"
        },
        {
            "key": 7,
            "value": "0"
        },
        {
            "key": 8,
            "value": "0"
        },
        {
            "key": 9,
            "value": "0"
        },
        {
            "key": 10,
            "value": "0"
        },
        {
            "key": 11,
            "value": "0"
        },
        {
            "key": 12,
            "value": "0"
        },
        {
            "key": 13,
            "value": "0"
        },
        {
            "key": 14,
            "value": "0"
        },
        {
            "key": 15,
            "value": "0"
        },
        {
            "key": 16,
            "value": "0"
        }
    ]
};

var queryData = {
    "version": 0,
    "cid": "clubD098628898",
    "type": 0,
    "cmd": 2
};

function close() {
    $.ajax({
        type: 'POST',
        url: url ,
        dataType: "json",
        data: JSON.stringify(closeData),
        contentType: "application/json;charset=UTF-8",
        //请求成功的回调函数
        success: function(data){
            console.log(data);
        }
    });
}

function open(){
    $.ajax({
        type: 'POST',
        url: url,
        dataType: "json",
        data: JSON.stringify(openData),
        contentType: "application/json;charset=UTF-8",
        success: function(data){
            console.log(data);
        }
    });
}

function query() {
    $.ajax({
        type : "POST",
        url : url,
        dataType: "json",
        data: JSON.stringify(queryData),
        contentType: "application/json;charset=UTF-8",
        success : function (data) {
            console.log(data);
            $("#queryResult").html("<p>"+data.msg+"</p>")
        }
    });
}
